import type { ConvertParams, ConvertResponse } from '@/types/api'
import request from './config'

export const videoApi = {
  /**
   * 将视频转换为GIF
   * @param params 转换参数
   * @param onUploadProgress 上传进度回调
   */
  convertToGif: async (
    params: ConvertParams,
    onUploadProgress?: (progressEvent: any) => void
  ) => {
    const formData = new FormData()
    formData.append('video', params.video)
    formData.append('quality', params.quality)
    formData.append('start_time', params.start_time.toFixed(3))
    formData.append('end_time', params.end_time.toFixed(3))

    return request.post<ConvertResponse>('/convert', formData, {
      responseType: 'blob',
      onUploadProgress,
      headers: {
        'Content-Type': 'multipart/form-data',
      },
    })
  },
} 